<?php
/**
 * XmuSlh, web platform of Student Association Federation of Xiamen University
 * 
 * Rewritting one or some pages of StatusNet. 
 * To get the original version, please visit <http://status.net/>.
 * 
 * StatusNet, the distributed open-source microblogging tool
 * 
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Login action.
 * Use session to hold the position and the logined information.
 * 
 * 用户登录的action.
 * 
 * @author		ytukie <ytukie@gmail.com>
 * @version		0.1
 */

// XmuSlh only.
if ( !defined('XMUSLH')) { exit(1); }

// Requirements.
require_once INSTALLDIR . '/lib/slh_util.php';

class LogoutAction extends Action
{
	function handle($args)
	{
		parent::handle($args);
		
		if ( !slh_logged_in()) {
			$this->clientError('没有登录就想登出啊亲.');
			
		} else {
			slh_set_user(null);
			slh_set_usertitle(null);
			slh_set_userrights(null);
			
			slh_real_login(false);
		
			// Forget me?
			setcookie("username", $this->username, time() - 3600*24*7);
         	setcookie("password", $this->password, time() - 3600*24*7);
			
			slh_redirect(slh_action2url('publicnews'), 303);
		}
	}
}
?>